<template>
  <div>
    <h2>子组件</h2>
    <button @click="handclick">获取父组件数据</button>
  </div>
</template>

<script>
export default {
  name: 'Child-1',
  data() {
    return {
      num: 12,
      name: '张三'
    }
  },
  methods: {
    fn() {
      console.log('子组件的点击事件')
    },
    handclick() {
      console.log(this.$parent.num)
      this.$parent.fn()
    }
  },
  mounted() {}
}
</script>

<style lang="scss" scoped></style>
